package com.jqb.struts2annotation.action;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;

import com.opensymphony.xwork2.ActionSupport;

/**
 * 命名空间
 */
@Namespace("/demo")
/**
 * Action访问路径及结果视图
 */
@Action(value = "annotationLoginAction", results = {
		@Result(name = "success", location = "/demo/annotationlogin.jsp"),
		@Result(name = "input", location = "/demo/error.jsp") })
/**
 * 拦截器
 @InterceptorRef(value="defaultStack")
 @InterceptorRefs({@InterceptorRef(""),@InterceptorRef("")})
 */
/**
 * 异常
 @ExceptionMapping(exception="",result="")
 @ExceptionMappings({@ExceptionMapping(exception="",result=""),@ExceptionMapping(exception="",result="")})
 */
public class AnnotationLoginAction extends ActionSupport {

	private static final long serialVersionUID = 1L;

	private String username;
	private String password;

	@Override
	public String execute() throws Exception {
		if (username.equals("admin")) {
			return SUCCESS;
		} else {
			return INPUT;
		}

	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}
}
